package okw.database;

import java.io.Serializable;

public class Voter extends core.modules.database.SuperVoter implements Serializable {

	private static final long serialVersionUID = -9160430715726465686L;

	private Boolean hasVoted = false;
	private Election election;
	
	public Voter() {
		super();
	}

	public Voter(String name, String surname, String address,
			String identificationField, Election election) {
		super(name, surname, address, identificationField);
		addToElection(election);
	}

	public Boolean getHasVoted() {
		if(hasVoted == null)
			return false;
		return hasVoted;
	}

	public void setHasVoted(Boolean hasVoted) {
		this.hasVoted = hasVoted;
	}

	public Election getElection() {
		return election;
	}

	public void setElection(Election election) {
		this.election = election;
	}

	public void addToElection(Election election) {
		this.setElection(election);
		election.getVoters().add(this);
	}

	public void removeFromElection(Election election) {
		this.setElection(null);
		election.getVoters().remove(this);
	}
}
